//
//  BaseViewController.m
//  collageForZhang
//
//  Created by lht on 16-5-26.
//  Copyright (c) 2016年 zhshy. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.view setBackgroundColor:BackgroundColor];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)viewWillAppear:(BOOL)animated{
    
    UIViewController *rootVC = [[self.navigationController viewControllers] objectAtIndex:0];
    if ([self isKindOfClass:[rootVC class]]) {
        self.tabBarController.tabBar.hidden = NO;
        if (self.tabBarController.tabBar.frame.origin.y != self.view.frame.size.height) {
            self.tabBarController.tabBar.frame = CGRectMake(self.tabBarController.tabBar.frame.origin.x, self.tabBarController.tabBar.frame.origin.y, self.tabBarController.tabBar.frame.size.width, 50);
        }
    }else{
        UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 18, 36)];
        [backButton setBackgroundImage:[UIImage imageNamed:@"Back"] forState:UIControlStateNormal];
        [backButton addTarget:self action:@selector(backAct:) forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithCustomView:backButton];
        self.navigationItem.leftBarButtonItem = button;
        
        self.tabBarController.tabBar.hidden = YES;
        if (self.tabBarController.tabBar.frame.origin.y != self.view.frame.size.height) {
            self.tabBarController.tabBar.frame = CGRectMake(self.tabBarController.tabBar.frame.origin.x, self.tabBarController.tabBar.frame.origin.y, self.tabBarController.tabBar.frame.size.width, 0);
        }
    }
    
    _tittleLbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 20, 50)];
    _tittleLbl.textColor = [UIColor blackColor];
    _tittleLbl.font = [UIFont boldSystemFontOfSize:17];
    self.navigationItem.titleView = _tittleLbl;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
-(IBAction)backAct:(id)sender{
    [self.navigationController popViewControllerAnimated:YES];
}
@end
